package com.neuedu.hw_20190215;

import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Hw08 {
    public static void main(String[] args) {
        test();
    }

    public static void test(){
        int count0=0,count1=0,count2=0;
        Scanner scanner = new Scanner(System.in);
        System.out.print("请输入一个字符串：");
        String str1=scanner.next();

        for (int i = 0; i < str1.length(); i++) {
            if (str1.charAt(i)>='0'&&str1.charAt(i)<='9'){
                count0++;
            }else if (str1.charAt(i)>='a'&&str1.charAt(i)<='z'||str1.charAt(i)>='A'&&str1.charAt(i)<='Z'){
                count1++;
            }
        }
        char[] c = str1.toCharArray();//将字符串放在一个char类型的数组中
        for(int i = 0; i < c.length; i ++)
        {
             String len = Integer.toBinaryString(c[i]);
             if(len.length() > 8)
                 count2++;
        }
            System.out.println("输入字符串为："+str1+"\n数字出现的次数为："+count0+"\n英文字母出现的次数为："
            +count1+"\n中文字符出现的次数为："+count2);

    }
}
